//
//  imageViewController.m
//  brilliant baby
//
//  Created by 남웅 백 on 10. 7. 29..
//  Copyright 2010 brilliant baby. All rights reserved.
//

#import "imageViewController.h"


@implementation imageViewController

@synthesize delegate;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil delegate:(id)delegateOrNil{
	if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
        delegate = delegateOrNil;
    }
	// create buttons
	button1 = [self CreateButton:@"1" type:UIButtonTypeRoundedRect view:self.view frame:CGRectMake(90.0,209.0,40.0,39.0) target:self action:@selector(touchNumber_1)];
	button2 = [self CreateButton:@"2" type:UIButtonTypeRoundedRect view:self.view frame:CGRectMake(141.0,209.0,40.0,39.0) target:self action:@selector(touchNumber_2)];
	button3 = [self CreateButton:@"3" type:UIButtonTypeRoundedRect view:self.view frame:CGRectMake(193.0,209.0,40.0,39.0) target:self action:@selector(touchNumber_3)];
	button4 = [self CreateButton:@"4" type:UIButtonTypeRoundedRect view:self.view frame:CGRectMake(90.0,258.0,40.0,39.0) target:self action:@selector(touchNumber_4)];
	button5 = [self CreateButton:@"5" type:UIButtonTypeRoundedRect view:self.view frame:CGRectMake(141.0,258.0,40.0,39.0) target:self action:@selector(touchNumber_5)];
	button6 = [self CreateButton:@"6" type:UIButtonTypeRoundedRect view:self.view frame:CGRectMake(193.0,258.0,40.0,39.0) target:self action:@selector(touchNumber_6)];
	button7 = [self CreateButton:@"7" type:UIButtonTypeRoundedRect view:self.view frame:CGRectMake(90.0,307.0,40.0,39.0) target:self action:@selector(touchNumber_7)];
	button8 = [self CreateButton:@"8" type:UIButtonTypeRoundedRect view:self.view frame:CGRectMake(141.0,307.0,40.0,39.0) target:self action:@selector(touchNumber_8)];
	button9 = [self CreateButton:@"9" type:UIButtonTypeRoundedRect view:self.view frame:CGRectMake(193.0,307.0,40.0,39.0) target:self action:@selector(touchNumber_9)];
	button0 = [self CreateButton:@"0" type:UIButtonTypeRoundedRect view:self.view frame:CGRectMake(141.0,355.0,40.0,39.0) target:self action:@selector(touchNumber_0)];
	buttonMinus = [self CreateButton:@"-" type:UIButtonTypeRoundedRect view:self.view frame:CGRectMake(90.0,355.0,40.0,39.0) target:self action:@selector(touchNumber_Minus)];
	buttonNil = [self CreateButton:@"." type:UIButtonTypeRoundedRect view:self.view frame:CGRectMake(193.0,355.0,40.0,39.0) target:self action:@selector(touchNumber_Nil)];
	buttonPower = [self CreateButton:@"P" type:UIButtonTypeRoundedRect view:self.view frame:CGRectMake(91.0,16.0,41.0,40.0) target:self action:@selector(touchPower)];
	buttonMenu = [self CreateButton:@"M" type:UIButtonTypeRoundedRect view:self.view frame:CGRectMake(200.0,23.0,27.0,26.0) target:self action:@selector(touchMenu)];
	buttonMute = [self CreateButton:@"T" type:UIButtonTypeRoundedRect view:self.view frame:CGRectMake(148.0,129.0,31.0,27.0) target:self action:@selector(touchMute)];
	buttonVolPlus = [self CreateButton:@"V+" type:UIButtonTypeRoundedRect view:self.view frame:CGRectMake(94.0,86.0,46.0,50.0) target:self action:@selector(touchVolPlus)];
	buttonVolMinus = [self CreateButton:@"V-" type:UIButtonTypeRoundedRect view:self.view frame:CGRectMake(94.0,136.0,46.0,50.0) target:self action:@selector(touchVolMinus)];
	buttonChUp = [self CreateButton:@"U" type:UIButtonTypeRoundedRect view:self.view frame:CGRectMake(185.0,86.0,46.0,50.0) target:self action:@selector(touchChUp)];
	buttonChDown = [self CreateButton:@"D" type:UIButtonTypeRoundedRect view:self.view frame:CGRectMake(185.0,136.0,46.0,50.0) target:self action:@selector(touchChDown)];
	 
	//image load
	imgNumber_1 = [UIImage imageNamed:@"number_1.png"];
	imgNumber_2 = [UIImage imageNamed:@"number_2.png"];
	imgNumber_3 = [UIImage imageNamed:@"number_3.png"];
	imgNumber_4 = [UIImage imageNamed:@"number_4.png"];
	imgNumber_5 = [UIImage imageNamed:@"number_5.png"];
	imgNumber_6 = [UIImage imageNamed:@"number_6.png"];
	imgNumber_7 = [UIImage imageNamed:@"number_7.png"];
	imgNumber_8 = [UIImage imageNamed:@"number_8.png"];
	imgNumber_9 = [UIImage imageNamed:@"number_9.png"];
	imgNumber_0 = [UIImage imageNamed:@"number_0.png"];
	imgNumber_minus = [UIImage imageNamed:@"number_minus.png"];
	imgNumber_nil = [UIImage imageNamed:@"number_nil.png"];
	imgPower = [UIImage imageNamed:@"power.png"];
	imgMenu = [UIImage imageNamed:@"menu.png"];
	imgMute = [UIImage imageNamed:@"mute.png"];
	imgChUp = [UIImage imageNamed:@"channel_up.png"];
	imgChDown = [UIImage imageNamed:@"channel_down.png"];
	imgVolPlus = [UIImage imageNamed:@"vol_plus.png"];
	imgVolMinus = [UIImage imageNamed:@"vol_minus.png"];

	//button image setting
	[button1 setImage:imgNumber_1 forState:UIControlStateNormal];
	[button2 setImage:imgNumber_2 forState:UIControlStateNormal];
	[button3 setImage:imgNumber_3 forState:UIControlStateNormal];
	[button4 setImage:imgNumber_4 forState:UIControlStateNormal];
	[button5 setImage:imgNumber_5 forState:UIControlStateNormal];
	[button6 setImage:imgNumber_6 forState:UIControlStateNormal];
	[button7 setImage:imgNumber_7 forState:UIControlStateNormal];
	[button8 setImage:imgNumber_8 forState:UIControlStateNormal];
	[button9 setImage:imgNumber_9 forState:UIControlStateNormal];
	[button0 setImage:imgNumber_0 forState:UIControlStateNormal];
	[buttonMinus setImage:imgNumber_minus forState:UIControlStateNormal];
	[buttonNil setImage:imgNumber_nil forState:UIControlStateNormal];
	[buttonPower setImage:imgPower forState:UIControlStateNormal];
	[buttonMenu setImage:imgMenu forState:UIControlStateNormal];
	[buttonMute setImage:imgMute forState:UIControlStateNormal];
	[buttonVolPlus setImage:imgVolPlus forState:UIControlStateNormal];
	[buttonVolMinus setImage:imgVolMinus forState:UIControlStateNormal];
	[buttonChUp setImage:imgChUp forState:UIControlStateNormal];
	[buttonChDown setImage:imgChDown forState:UIControlStateNormal];
	
    return self;
}

- (IBAction) changeView{
	[delegate changeView];
}

//touch
- (IBAction) touchNumber_1{

}

- (IBAction) touchNumber_2{}
- (IBAction) touchNumber_3{}
- (IBAction) touchNumber_4{}
- (IBAction) touchNumber_5{}
- (IBAction) touchNumber_6{}
- (IBAction) touchNumber_7{}
- (IBAction) touchNumber_8{}
- (IBAction) touchNumber_9{}
- (IBAction) touchNumber_0{}
- (IBAction) touchNumber_Minus{}
- (IBAction) touchNumber_Nil{}
- (IBAction) touchVolPlus{}
- (IBAction) touchVolMinus{}
- (IBAction) touchChUp{}
- (IBAction) touchChDown{}
- (IBAction) touchPower{}
- (IBAction) touchMenu{}
- (IBAction) touchMute{}


//for make button
- (UIButton *)CreateButton:(NSString *)title type:(UIButtonType)type view:(UIView *)view frame:(CGRect)frame target:(id)target action:(SEL)action{
	UIButton *button = [[UIButton buttonWithType:type] retain];
	button.frame = frame;
	[button setTitle:title forState:UIControlStateNormal];
	[button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
	
	[view addSubview:button];
	return button;
}





/*
 // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
        // Custom initialization
    }
    return self;
}
*/

/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
}
*/

/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc {
    [super dealloc];
}


@end
